package com.ruoyi.market.factory;

import com.ruoyi.common.utils.ApplicationContextUtil;
import com.ruoyi.market.enums.SmsEnum;
import com.ruoyi.market.service.ISmsInfoService;
import com.ruoyi.market.service.sms.DaHanSmsInfoService;
import com.ruoyi.market.service.sms.DanMiSmsInfoService;
import com.ruoyi.market.service.sms.MiaoXinSmsInfoService;
import com.ruoyi.market.service.sms.WoLianSmsInfoService;

import java.util.HashMap;
import java.util.Map;

public class SmsInfoFactory {

    private static Map<String, Class<? extends ISmsInfoService>> serviceMap = new HashMap<>();
    static {

        serviceMap.put(SmsEnum.DANMI.getValue(), DanMiSmsInfoService.class);
        serviceMap.put(SmsEnum.DAHAN.getValue(), DaHanSmsInfoService.class);
        serviceMap.put(SmsEnum.MIAOXIN.getValue(), MiaoXinSmsInfoService.class);
        serviceMap.put(SmsEnum.WOLIAN.getValue(), WoLianSmsInfoService.class);
    }

    public static ISmsInfoService getService(String type){
        if (serviceMap.containsKey(type)){
            Class<? extends ISmsInfoService> aClass = serviceMap.get(type);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
}
